package flown.game;

import java.awt.Rectangle;


/**
 * @author flown
 */


public class GameObject
{
    protected Rectangle rect;///< x,y,width,height

    public GameObject() { this.rect = new Rectangle(); }
    public GameObject(Rectangle rect) { this.rect = rect; };
    public GameObject(int x, int y, int width, int height)
    {
        this.rect = new Rectangle(x, y, width, height);

    }

    /**
     *
     * @param go GameObject
     * @return 是否相交
     */
    public final boolean Intersects(GameObject go) { return this.rect.intersects(go.rect); }

    /**
     *
     * @param r Rectangle
     * @return 是否相交
     */
    public final boolean Intersects(Rectangle r) { return this.rect.intersects(r); }

    /**
     *
     * @param x 横坐标
     * @param y 纵坐标
     * @param width 宽
     * @param height 高
     * @return 是否相交
     */
    public final boolean Intersects(int x, int y, int width, int height)
    {
        Rectangle r = new Rectangle(x, y, width, height);
        return this.rect.intersects(r);
    }

}



